home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / AEObject-Edition1.0.2 Sample / Structs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-09  |  8.3 KB  |  254 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *  Apple Developer Technical Support
  4.  *
  5.  *  Text section handling routines
  6.  *
  7.  *  Program:    AEObject-Edition Sample
  8.  *  File:       AESampStructs.h -    C Source
  9.  *
  10.  *  by:         C.K. Haun <TR>
  11.  *
  12.  *  Copyright © 1990-1992 Apple Computer, Inc.
  13.  *  All rights reserved.
  14.  *
  15.  *------------------------------------------------------------------------------
  16.  * This file contains all the structure definitions for the structs I use
  17.  * in this sample
  18. *----------------------------------------------------------------------------*/
  19.  
  20.  
  21. #ifndef __STRUCTS__
  22. #define __STRUCTS__
  23. /* Structures */
  24. struct myLine {                /* my own structure for defining a line */
  25.     Point start;
  26.     Point end;
  27. };
  28. typedef struct myLine myLine, *myLinePtr, **myLineHandle;
  29. /* my text section (pub or sub) structure.  I will probably make this  */
  30. /* a struct for all my editions soon. */
  31. struct textSection {
  32.     struct textSection **nextSection;
  33.     Boolean publishing;  /* I don't really need to include this flag, but I would */
  34.                         /* rather do it here than dereferencing the section handle */
  35.                         /* all the time, makes the code a little more readable */
  36.     Boolean bordered;  /* this section should currently be bordered */
  37.     short startChar;
  38.     short endChar;
  39.     Handle    theText;
  40.     SectionHandle theSection;
  41.     unsigned long theID;
  42. };
  43. typedef struct textSection textSection, *textSectionPtr, **textSectionHandle;
  44.  
  45. /* Instead of using the handles I've used in the window structure, a */
  46. /* section list like this may be more helpful, particularly if you */
  47. /* will be working with a great many sections */
  48. struct mySectionData {
  49.     struct mySectionData **nextSection;
  50.     Boolean publishing;
  51.     Boolean bordered;
  52.     SectionHandle theSection;
  53.     Rect theRect;
  54.     short startChar;
  55.     short endChar;
  56.     Handle additionalData;
  57.     unsigned long theID;
  58. };
  59. typedef struct mySectionData mySectionData, *mySectionDataPtr,**mySectionDataHandle;
  60.  
  61.  
  62.  
  63. /* structure for the graphic elements in a document window */
  64. struct Shapes{
  65. short type;    /* what kind is this? */
  66. DescType aeType;
  67. Rect theRect;    /* what's it's rectangle? */
  68.  struct Shapes **nextShape;
  69. long shapeIndex;
  70. RGBColor theColor;    
  71. };
  72. typedef struct Shapes Shapes;
  73. typedef Shapes *ShapesPtr,**ShapesHandle;
  74.  
  75.  
  76. /* windowControl is the structure attached to every window I create (in the refCon */
  77. /* field) that contains all the information I need to know about the window. */
  78. /* data, procedure pointers for controlling, and anything else gets put in this */
  79. /* struct.  That makes my windows autonomous, almost object-like */
  80. struct windowControl {
  81.     unsigned long windowID;                                 /* master ID number for section recording */
  82.     ProcPtr drawMe;                                         /* content drawing procedure pointer */
  83.     ProcPtr clickMe;                                        /* content click routine */
  84.     ProcPtr saveMe;                                         /* document save procedure pointer */
  85.     ProcPtr closeMe;                                        /* document close procedure pointer */
  86.     ProcPtr sizeMe;
  87.     AliasHandle fileAliasHandle;                            /* alias for this document */
  88.     ShapesHandle theShapes;                                    /* list of shapes for this document */
  89.     unsigned short numShapes;                                /* so I can save a number in the file */
  90.     Rect selectionRect;                                     /* currently selected area in document */
  91.     Boolean hasSelection;                                   /* is there a selection? */
  92.     short currentAction;                                    /* what mode is document in */
  93.     short undoAction;                                       /* last completed action */
  94.     Boolean windowDirty;
  95.     mySectionDataHandle graphicSections;    
  96.     short numPubs;                                          /* count of active publishers */
  97.     Handle pubs;                                            /* handle containing section handles for publishers */
  98.     Handle pubRects;                                        /* where in the document the publisher is */
  99.     short numSubs;                                          /* count of active subscribers */
  100.     Handle subs;                                            /* handle containing section handles for subscribers */
  101.     Handle subRects;                                        /* where in the document the subscriber is */
  102.     Handle subDataHandle;                                   /* PICT data handles for each subscriber */
  103.     short numPicts;                                         /* number of non-sub PICTS */
  104.     Handle pictHandle;                                      /* handle to pic handles. This is needed when a user */
  105.     /* cancels a subscription, move the PICT to here */
  106.     Handle pictRects;                                       /* where in the document the subscriber is */
  107.     mySectionDataHandle textSections;
  108.     Rect textBox;
  109.     TEHandle boxHandle;
  110.     long windowIndex;                                        /* for AppleEvent information */
  111.  
  112. };
  113. typedef struct windowControl windowControl, *windowCPtr, **windowCHandle;
  114.  
  115.  
  116. /* A handy structure used to install AppleEvent handlers */
  117. struct AEinstalls{
  118.     AEEventClass theClass;
  119.     AEEventID    theEvent;
  120.     EventHandlerProcPtr    theProc;
  121. };
  122. typedef struct AEinstalls AEinstalls;
  123. /* Ditto for coercion handlers */
  124. struct CoercionInstalls{
  125.     DescType fromType;
  126.     DescType toType;
  127.     ProcPtr    theProc;
  128.     Boolean isDesc;  /* will usually be FALSE, System coercion */
  129. };
  130. typedef struct CoercionInstalls CoercionInstalls;
  131.  
  132. /* Here are the structures I am using to define the type of  */
  133. /* object you want acted upon by an event.  Probably not very useful */
  134. /* outside of this sample */
  135. struct WindowObjectDef {
  136. DescType form;
  137. union {
  138. Str63 name;
  139. long index;
  140. } u;
  141. };
  142. typedef struct WindowObjectDef WindowObjectDef, *WindowObjectDefPtr, **WindowObjectDefHandle;
  143. struct TextObjectDef {
  144. DescType form;
  145. union {
  146. Str63 name;
  147. long index;
  148. } u;
  149. Boolean andWord;
  150. long wordNumber;
  151. };
  152. typedef struct TextObjectDef TextObjectDef, *TextObjectDefPtr, **TextObjectDefHandle;
  153.  
  154. struct ShapeObjectDef {
  155. short type;
  156. DescType form;
  157. union {
  158. Str63 name;
  159. long index;
  160. } u;
  161.  
  162. };
  163. typedef struct ShapeObjectDef ShapeObjectDef, *ShapeObjectDefPtr, **ShapeObjectDefHandle;
  164.  
  165.  
  166. /* Here are the structures that define my Tokens, that I pass */
  167. /* back and hand around during AEResolve */
  168. /* All these things are designed to give me all the info I */
  169. /* need to take an event action on an object */
  170. /* I didn't create a structure for my window token, since it's so simple */
  171. /* (just the window pointer) */
  172.  
  173. /* structure of my cText token */
  174. struct CTextObject {
  175. TEHandle theText;
  176. WindowPtr theOwningWindow;
  177. };
  178. typedef struct CTextObject CTextObject, *CTextObjPtr,**CTextObjHandle;
  179.  
  180. /* my word token */
  181. struct CWordObject {
  182. TEHandle theText;    /* need this for setting data */
  183. WindowPtr theOwningWindow;
  184. long startPos;
  185. long endPos;
  186. };
  187. typedef struct CWordObject CWordObject, *CWordObjPtr,**CWordObjHandle;
  188. /* structure of my cGraphicShape token */
  189. struct CShapeObject {
  190. WindowPtr theOwningWindow;
  191. ShapesHandle theShape;
  192. long shapeNumber;
  193. DescType type;
  194. };
  195. typedef struct CShapeObject CShapeObject, *CShapeObjPtr,**CShapeObjHandle;
  196.  
  197. /* structure of my Property token */
  198. struct PropertyToken {
  199. DescType owningTokenType;
  200. WindowPtr inWindow;
  201. union {
  202. ShapesHandle shapeHandle;
  203. TEHandle textHandle;
  204. WindowPtr window;
  205. } token;
  206. DescType theProperty;
  207. DescType theDataType;
  208. Handle theData;
  209. };
  210. typedef struct PropertyToken PropertyToken, *PropertyTPtr,**PropertyTHdl;
  211.  
  212.  
  213. /* My preferences structure */
  214. struct prefStruct {
  215. long version;
  216. Boolean prefsChanged;
  217. Boolean bringAEUp;
  218. Boolean verboseAE;
  219. Boolean saveWindDef;
  220. WindowObjectDef savedWOD;
  221. Boolean saveTextDef;
  222. TextObjectDef savedTOD;
  223. Boolean saveShapeDef;
  224. ShapeObjectDef savedSOD;
  225. Boolean saveInteract;
  226. short localInteraction;
  227. short sendInteraction;
  228. Boolean layerSwitch;
  229. Boolean saveTarget;
  230. short targetMode;
  231. Boolean saveReply;
  232. short replyMode;
  233. };
  234. typedef struct prefStruct prefStruct, *prefStructPtr, **prefStructHandle;
  235.  
  236. /* I thought about making this a union, but I use it so infrequently I didn't want it to get confusing */
  237. struct NewElementData{
  238. Rect theRect;
  239. long long1;
  240. long long2;
  241. Str63 name;
  242. };
  243. typedef struct NewElementData NewElementData,*NewElementDataPtr,**NewElementDataHdl;
  244.  
  245.  
  246. /* for passing back intl text information */
  247. struct WritingCode {
  248. short theScriptCode;
  249. short theLangCode;
  250. };
  251. typedef struct WritingCode WritingCode,*WritingCodePtr,**WritingCodeHdl;
  252.  
  253.  
  254. #endif